home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / postscript.746 < prev    next >
Text File  |  1992-02-06  |  15KB  |  299 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f3\fmodern Ohlfs;\f2\fmodern Courier;\f1\fswiss Helvetica;}
  2. \paperw13040
  3. \paperh10800
  4. \margl120
  5. \margr120
  6. {\colortbl\red0\green0\blue0;}
  7. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ul0\fs28 debugging PostScript fonts\
  8. \
  9. Q:  My fonts won't work with the appkit! What can I do?\
  10. \
  11. A:  Yikes!! This is not an easy question to answer, as fonts are very complicated and any number of things can be wrong.  However, there are many things you can do to narrow down the scope of the problem.\
  12. \
  13. There are a couple of ways in which a malformed or mis-installed PostScript font manifests itself. Sometimes  the font name simply doesn't appear in the font panel of an application. Sometimes the new font name does appear, but when selected the display reads:\
  14. \
  15.  
  16. \f3\fs24     <<Unusable Font>>\
  17.  
  18. \f0\fs28     \
  19. And sometimes when a font is selected and previewed within the font panel, the name of the font will appear in the display, but it will look exactly like your default font (as a matter of fact it will be displayed in your default font). In this case, if you look in the console, you will likely see error messages which look like this:\
  20. \
  21.  
  22. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\f3\fs20\fc0     Feb 15 12:36:57 me Edit[13537]: DPS client library error: PostScript program error, DPSContext 48160\
  23.     Feb 15 12:36:58 me Edit[13537]: %%[ Error: typecheck; OffendingCommand: setshared ]%%\
  24.     Feb 15 12:36:58 me Edit[13537]: DPS client library error: PostScript program error, DPSContext 48160\
  25.     Feb 15 12:36:58 me Edit[13537]: %%[ Error: typecheck; OffendingCommand: setfont ]%%\
  26.     \
  27.  
  28. \f0\fs28 So, how do you fix it?\
  29. \
  30. First, there is a bug in the appkit which may cause the erroneous 
  31. \f3\fs24 <<unusable font >>
  32. \f0\fs28  message. So the first thing that you should do when debugging a newly installed font is to make sure that you are not encountering this bug.\
  33. \
  34. The following steps will cause the bug:\
  35. \
  36.     • Add a font to 
  37. \b ~/Library/Fonts
  38. \b0  (or 
  39. \b /LocalLibrary/Fonts
  40. \b0 ).\
  41.     • In a shell, run 
  42. \b buildafmdir
  43. \b0  on that directory.\
  44. \
  45. There are a couple of other dependencies, but in general the new font will be 
  46. \f3\fs24 <<unusable>>
  47. \f0\fs28 .  A power-cycle will not fix this—the directory is in a bad state. The user level work-around is:\
  48. \
  49.  
  50. \fi-800\li800     • Move a font out of the directory.  Then move it back in (thus updating the modified time of the directory).\
  51.     • Remove the 
  52. \b .afmcache
  53. \b0 , 
  54. \b .fontdirectory
  55. \b0 , and 
  56. \b .fontlist
  57. \b0  files from the font directory.\
  58.     • Launch an application with a Font Panel.  Bring up the Font Panel.  You should get an alert saying "Incorporating info about new fonts...".  All correct fonts in the directory should now be usable.\
  59.  
  60. \fi0\li0 \
  61. The underlying cause here is that in Release 2 there are two programs that are run on the font directory:  
  62. \b buildafmdir
  63. \b0  (which creates 
  64. \b .fontdirectory
  65. \b0  and 
  66. \b .fontlist
  67. \b0 ) and 
  68. \b cacheAFMData
  69. \b0  (which creates 
  70. \b .afmcache
  71. \b0 ).   When you let the kit notice that there are new fonts, it does the right thing and runs both.  If you just run 
  72. \b buildafmdir
  73. \b0  by hand, you will sometimes screw up the caching of the AFM data.  
  74. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0 The only reason
  75. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc0 s
  76. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0  you 
  77. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc0 might
  78. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0  run 
  79. \b buildafmdir
  80. \b0  yourself 
  81. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc0 would be: (1) to debug
  82. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0  font
  83. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc0 s,
  84. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0  or
  85. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc0  (2)
  86. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0  
  87. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc0 because 
  88. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0 the appkit didn't run it for you
  89. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc0 , for some reason
  90. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0 . This is how you run the 
  91. \b buildafmdir
  92. \b0  utility by hand:
  93. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc0 \
  94.  
  95. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0 \
  96.  
  97. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\f3\fs24     % buildafmdir ~/Library/Fonts\
  98.  
  99. \fs22     \
  100.  
  101. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\fs28\fc0 You may not get the alert saying "Incorporating info about new fonts..." immediately after launching an application. This is because the appkit discovers new fonts lazily.  For applications that use the FontManager when they launch, new fonts are incorporated at launch.  For other applications, it won't happen until you bring up the Font Panel.  Bringing up the Font Panel will always do it.\
  102. \
  103.  
  104. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc0 The best way to install a font is to just copy it into a font directory. In fact, it may also be best to remove 
  105. \b .fontdirectory
  106. \b0 , 
  107. \b .fontlist
  108. \b0 , and 
  109. \b .afmcache
  110. \b0  after installing a new font, and launching a new application.\
  111. \
  112.  
  113. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600 Once you have verified that the Workspace Manager has properly recognized the newly installed font, you should determine whether or not the problems that you are having lie with the installation of the font.  A font—let's call it 
  114. \b Scrabble
  115. \b0 —should have the following file system structure: there should be 
  116. \i at least
  117. \i0  these three directories in 
  118. \b ~/Library/Fonts
  119. \b0 , or
  120. \b  /NeXTLibrary/Fonts
  121. \b0  or 
  122. \b /LocalLibrary/Fonts
  123. \b0  :\
  124.     
  125. \b Scrabble.font
  126. \b0 \
  127.     
  128. \b afm
  129. \b0 \
  130.     
  131. \b outline
  132. \b0 \
  133. (If any font contains bitmap fonts, then a 
  134. \b bitmap
  135. \b0  directory is required as well.) The 
  136. \b Scrabble.font
  137. \b0  directory must contain all of the files which describe the font: 
  138. \b Scrabble and Scrabble.afm
  139. \b0 . 
  140. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc0 Any release 2 software (2.0, 2.1,...) uses the PostScript outline, .afm
  141. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0 ,
  142. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc0  and .bepf files out of the containing .font directory, whereas the 1.0 software requires sym
  143. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0 bolic 
  144. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc0 links in the outline, afm, and bitmap directories.\
  145.  
  146. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600 \
  147. The file 
  148. \b Scrabble
  149. \b0  contains the PostScript program which describes the outline of each individual character. The file 
  150. \b Scrabble.afm
  151. \b0  contains the width information for each character. Both the outline file and the afm file contain the name of the font, and the font family among other information about the font. The file names 
  152. \i must
  153. \i0  match the font names which appear within the files.\
  154. \
  155. Taking our Scrabble example, in the Scrabble file we should see the following entries:\
  156. \
  157.  
  158. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\f3\fs24\fc0     /FullName (Scrabble) readonly def\
  159.     /FamilyName (Scrabble) readonly def\
  160.     /FontName /Scrabble def\
  161.  
  162. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\fs28 \
  163. And in the Scrabble.afm file, we should see these entries:\
  164. \
  165.  
  166. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\f3\fs24\fc0     FontName Scrabble\
  167.     FullName Scrabble\
  168.     FamilyName Scrabble\
  169.     Weight Medium\
  170.  
  171. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\fs28 \
  172. The names change a little bit when you consider that many font families will provide both bold and italic versions. Here's how a bold version of the Scrabble font would look:\
  173. \
  174. The directory would be named 
  175. \b Scrabble-Bold.font
  176. \b0 .\
  177. \
  178. The outline file would be named 
  179. \b Scrabble-Bold
  180. \b0 . It would contain the following entries:\
  181. \
  182.  
  183. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\f3\fs24\fc0     /FullName (Scrabble Bold) readonly def\
  184.     /FamilyName (Scrabble) readonly def\
  185.     /FontName /Scrabble-Bold def\
  186.  
  187. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\fs28 \
  188. The afm file would be named 
  189. \b Scrabble-Bold.afm
  190. \b0 . It would contain the following entries:\
  191. \
  192.  
  193. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\f3\fs24\fc0     FontName Scrabble-Bold\
  194.     FullName Scrabble Bold\
  195.     FamilyName Scrabble\
  196.     Weight Bold\
  197.  
  198. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\fs28 \
  199. It is important that the FullName be the FamilyName followed by whatever you want to appear in the second (Typeface) browser of the FontPanel.  In the above example, the word "Scrabble" would appear in the Family browser in the FontPanel and the word "Bold" will appear in the Typeface browser.  If the FullName of the font is exactly equal to the FamilyName, then the word that appears in the second column will be the value of the Weight field in the afm file.  (This would have been the case for the example "FullName Scrabble" above.)\
  200. \
  201. And finally, on 1.0 you must link these files into the afm and outline directories. Use the following commands to do that:\
  202. \
  203.  
  204. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\f3\fs24     % cd ~/Library/Fonts/afm\
  205.     % ln -s ../Scrabble.font/Scrabble.afm\
  206.     % cd ../outline\
  207.     % ln -s ../Scrabble.font/Scrabble\
  208.  
  209. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\fs28     \
  210. If your font contains bitmap files, you must link those files into the bitmap directory.\
  211. \
  212. Once you think that you have your fonts in order, 
  213. \fc0 you will have to re-launch an application (and bring up the Font Panel) to take advantage of the new fonts.  When an application is launched, the appkit can detect that new fonts have been added to the directory, and it runs 
  214. \b buildafmdir
  215. \b0  and 
  216. \b cacheAFMdata
  217. \b0 , as described above. \
  218. \
  219. Once you have correctly installed the font, there may still be some problems. Now, you must determine whether the problem lies within the PostScript outline file or with the afm file. The manner in which the font fails can sometime indicate which is the guilty party. If you are receiving an error in the font panel says the font is unusable, then the afm file is guilty.\
  220. \
  221. Another way to determine whether the fault is with the outline file or with the afm file is to run the outline file through 
  222. \b pft
  223. \b0 .\
  224. \
  225. Here's how to do that (the commands that you type are in bold):\
  226. \
  227.  
  228. \pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\f3\fs24\fc0     trilithon \{ 117 \} 
  229. \f2\b pft
  230. \f3\b0 \
  231.     Connection to PostScript established.\
  232.  
  233. \f2\b     (/Net/foobar/home/squiggle/Library/Fonts/Scrabble.font/Scrabble) run\
  234.  
  235. \f3\b0     %%[ Error: undefined; OffendingCommand:  ]%%\
  236.  
  237. \f2\b     quit\
  238.  
  239. \b0     pft: Connection to Window Server closed\
  240.  
  241. \f3     trilithon \{ 118 \} \
  242.  
  243. \f0\fs28 \
  244. You may have noticed that the full pathname of the font's outline file is required. 
  245. \b  
  246. \b0 The command
  247. \b  pft
  248. \b0  merely opens a connection to the window server, which has been running since you booted up your machine. The window server is always launched from the root directory, and you must give the pathname from the current directory of the window server, not your current directory.\
  249. \
  250. In the above 
  251. \b pft
  252. \b0  session the outline file had a syntax error in it, and the PostScript interpreter could not process it, producing an error. Of course, since PostScript error handling is archaic and does not inform you of the problem and where it exists, you must take further steps to discover just where that problem is. If you have it, you can use the DisplayTalk application to trace through the PostScript code, and it will identify the line on which the error occurs. Otherwise, you must resort to brute force method of debugging such as printing statements, and removing parts of the code a little bit at a time.\
  253. \
  254. While you are still connected to 
  255. \b pft
  256. \b0  you can look at the values of the font dictionary to see if things are as they should be. Refer to the Red Book (the PostScript Language Reference Manual) for more information on the structure of the font dictionary. Remember also that fonts are stored in the FontDirectory in the PostScript interpreter.\
  257. \
  258. Some common problems to look for when debugging your fonts:\
  259. \
  260. • Check for strange characters like <ctrl-Z> or <ctrl-D> characters at the end of the outline file. Often in the PC or MacIntosh world these characters are used to indicate end-of-job to the printer. However, it's not part of the PostScript language; it's really a printer protocol, and doesn't belong in a PostScript program.\
  261. \
  262. • Also, make sure that the carriage returns in the files are indeed carriage returns and not line feeds. Again, this is caused from the difference between file formats on a PC or MacIntosh and those on UNIX.\
  263. \
  264. • Since these files are ASCII and partially human-readable, you can look at the files. Sometimes just by looking at the files carefully, you will notice something that doesn't look right, and which will indeed be the problem. Check to make sure that entries are consistently capitalized. For example, if you saw the following:\
  265. \
  266.  
  267. \f3\fs24     FullName Scrabble\
  268.     FamilyName Scrabble\
  269.     weight standard\
  270.     Notice \
  271.     ItalicAngle 0.0\
  272.  
  273. \f0\fs28 \
  274. There's a big clue that the weight entry is incorrect.\
  275. \
  276. • The Weight entry has a discrete set of valid values. They are "Ultra Light", "Thin", "Light", "Extra Light", "Book", "Regular", "Plain", "Roman", "Medium", "Demi", "Demi-Bold", "Semi-Bold", "Bold", "Extra Bold", "Heavy", "Heavyface", "Black", "Ultra", "UltraBlack", "Fat", "ExtraBlack", and "Obese".\
  277.  
  278. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600 \
  279. For more information refer to the following documentation:\
  280. \
  281.  
  282. \i     Adobe Type 1 Font Format Book\
  283.     Preparing Fonts for NextStep (on-line in DL)\
  284.     The Red Book (Level 1 and Level 2)\
  285. \
  286.  
  287. \i0 or look at the fonts in /NextLibrary/Fonts for example fonts.\
  288.  
  289. \i \
  290.  
  291. \i0 QA746\
  292.  
  293. \i \
  294.  
  295. \i0 Valid for 1.0\
  296. Valid for 2.0\
  297. \
  298.  
  299.